<?php

/**
 * Kontrola filter form base class.
 *
 * @package    Rejestracja
 * @subpackage filter
 * @author     Michał Sobczak (smichal88@gmail.com)
 */
abstract class BaseKontrolaFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'data'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'idWizyta'   => new sfWidgetFormPropelChoice(array('model' => 'Wizyta', 'add_empty' => true)),
      'idPacjent'  => new sfWidgetFormPropelChoice(array('model' => 'Pacjent', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'data'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'idWizyta'   => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Wizyta', 'column' => 'idWizyta')),
      'idPacjent'  => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Pacjent', 'column' => 'idPacjent')),
    ));

    $this->widgetSchema->setNameFormat('kontrola_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Kontrola';
  }

  public function getFields()
  {
    return array(
      'idKontrola' => 'Number',
      'data'       => 'Date',
      'idWizyta'   => 'ForeignKey',
      'idPacjent'  => 'ForeignKey',
    );
  }
}
